<?php
	include('classess/login.php');
	
	if(isset($_SESSION['id'])){
		header('Location:dashboard/index.php');
	}
	
	$tr_admin = new trainee_login();	
	if(isset($_POST['user_email'])){
		$trn_login = $tr_admin->tr_login();		
	}

?>
<!DOCTYPE html>
<!--[if IE 8]> 				 <html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->

  <head>  	
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <meta name="description" content="RV Training Solutions provides Online Trainings and Classroom Training with live practical Training and more.">
		<meta name="keywords" content="Online Live Practical Training,Online classes, Online courses, Free online courses, Online RV Training Certification, Online tutoring, Online Training, RVCertification programs">
	<link rel="shortcut icon" href="../template/themes/images/favicon.ico" />
    
	<title>RV Training Solutions-Learning with Vipin</title>
    <!-- Bootstrap core CSS -->
    <link href="outer_css/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="outer_css/login.css" rel="stylesheet">
    <link href="outer_css/animate-custom.css" rel="stylesheet">
   	<link href="outer_css/custom.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="outer_js/html5shiv.js"></script>
      <script src="outer_js/respond.min.js"></script>
    <![endif]-->
  </head>
    <body>
    	<!-- start Login box -->
    	<div class="container" id="login-block">
    		<div class="row">
			    <div class="col-sm-6 col-md-4 col-sm-offset-3 col-md-offset-4">
			    	<h3 class="animated bounceInDown">Trainee Login</h3>
			       <div class="login-box clearfix animated flipInY">
			        	<div class="login-logo">
			        		<a href="#"><img src="img/login-logo.png" alt="Company Logo" /></a>
			        	</div> 
			        	<hr />
			        	<div class="login-form login-content">
							<?php
									if(isset($trn_login)){
							?>
			        		<div class="alert alert-error">
								  <button type="button" class="close" data-dismiss="alert">&times;</button>
								  	<?php echo $trn_login; ?>
									
							</div>
							<?php }?>
			        		<form action="<?php echo $_SERVER['PHP_SELF']; ?>?home=1" method="POST" name="trainee_login_form" >
								<label>Username</label>
						   		 <input type="text" placeholder="Email" name="user_email" id="user_email" required/> 
								 <label>Password</label>
						   		 <input type="password" name="user_pwd" id="user_pwd"  placeholder="Password"  required/> 
						   		 <label>
								 	<div class="login_submit_row_left">
										<label style="float:left; width:12%;"><input type="checkbox" name="rem_me" style="margin: 0%;"></label>
										<label style="float:left;margin-top: -3px; width: 75%; font-size:12px;">Remember Me</label>
								 		
										<label style="clear:both;"></label>
									</div>
									<div class="login_submit_row_right">
								 		<button type="button" class="btn btn-blue login_button">Login</button> 
									</div>
									<div style="clear:both;"></div>
								 <label>
							</form>	    		
			        	</div> 			        	
			       </div>		  	   	
			      
			    </div>
			</div>
    	</div>
     
      	<!-- End Login box -->
     	<footer class="container">
     		<p id="footer-text"><small>Copyright &copy; 2013 </small></p>
     	</footer>

        <script src="outer_js/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="outer_js/jquery-1.9.1.min.js"><\/script>')</script> 
        <script src="outer_js/bootstrap.min.js"></script> 
        <script src="outer_js/placeholder-shim.min.js"></script>        
        <script src="outer_js/custom.js"></script>
    </body>
</html>
<script>
	$ = jQuery.noConflict();
	$(document).ready(function(){	
		$('.login_button').click(function(){
						
			if($('#user_email').val() == "")
			{
				alert("Please enter a value for the \"Email\" field.");
				$('#user_email').focus();				
				return (false);
			}else if(($('#user_email').val().indexOf("\@") == -1) || ($('#user_email').val().indexOf(".")== -1) || isInvalidateEmail($('#user_email').val()))
			{
				alert("Invalid Email Address");
				$('#user_email').focus();
				return (false);
			}else if($('#user_pwd').val() == ''){			
				alert("Please enter a value for the \"Password\" field.");
				$('#user_pwd').focus();
				return (false);
			}else{
				document.trainee_login_form.submit();
			}

		});
		
	});

	function isInvalidateEmail(str)
	{
		var atpos=str.indexOf("@");
		var dotpos=str.lastIndexOf(".");
		if (atpos<1 || dotpos<atpos+2 || dotpos+2>=str.length)
		  {
		  return true;
		  }
		return false;
	}

</script>